package netWorkPrograming.test.test03;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author yangwenqi
 * @decs TODO
 * @date 2025/5/28
 */
public class ThreadPool {

    private ThreadPoolExecutor pool;

    public ThreadPool(int maxPoolSize , int queueSize){
        pool = new ThreadPoolExecutor(
                2 , maxPoolSize , 60 , TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(queueSize),
                new ThreadPoolExecutor.AbortPolicy()
        );
    }

    public void exec(Runnable task){
        pool.submit(task);
    }

}
